﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using ZFS.Library.Helper;
using ZFS.Model;
using ZFSData;
using ZFSData.InterFace;

namespace ZFS.ServerBusiness
{
    public class WCF_DictionaryManager : WCF_BaseManager<WCF_DictionaryManager>, IDictionary
    {
        public tb_Dictionary AddEntity(tb_Dictionary entity)
        {
            var result = Server.AddEntityByDic(ZipTools.CompressionObject(entity));
            return ZipTools.DecompressionObject(result) as tb_Dictionary;
        }

        public bool DeleteEntity(tb_Dictionary entity)
        {
            var result = Server.DeleteEntityByDic(ZipTools.CompressionObject(entity));
            return result;
        }

        public bool ExistEntity(tb_Dictionary entity)
        {
            var result = Server.ExistEntityByDic(ZipTools.CompressionObject(entity));
            return result;
        }

        public List<tb_Dictionary> GetDictionarys()
        {
            var result = Server.GetDictionarys();
            return ZipTools.DecompressionObject(result) as List<tb_Dictionary>;
        }

        public List<tb_Dictionary> GetModels(tb_Dictionary search)
        {
            var bytes = Server.GetModelsByDic(ZipTools.CompressionObject(search));
            return ZipTools.DecompressionObject(bytes) as List<tb_Dictionary>;
        }

        public List<tb_Dictionary> GetPagingModels(int pageIndex, int pageSize, out int totalCount, tb_Dictionary search, bool Asc = false)
        {
            var bytes = Server.GetPagingModelsByDic(pageIndex, pageSize, ZipTools.CompressionObject(search), Asc, out totalCount);
            return ZipTools.DecompressionObject(bytes) as List<tb_Dictionary>;
        }

        public bool UpdateEntity(tb_Dictionary entity)
        {
            return Server.UpdateEntityByDic(ZipTools.CompressionObject(entity));
        }
    }
}
